<?php
class ManageController extends AdminController
{
    public function init()
    {
        $this->tableName='cron';
        parent::init();
    }
    public function indexAction()
    {
        $this->list=$this->model->order('id asc')->getlist();
        $this->display();
    }
    public function addAction()
    {
        if (IS_POST) {
            if ($this->model->add($_POST)) {
                $this->success('添加成功');
            } else {
                $this->error('添加失败');
            }
        }
        $this->display();
    }
    public function editAction()
    {
        $zym_7=I('request.id');
        if ($zym_7 && $zym_6=$this->model->find($zym_7)) {
            if (IS_POST) {
                $zym_5=$_POST;
                if ($this->model->edit($zym_5)!==false) {
                    $this->success('修改成功');
                } else {
                    $this->error('修改失败');
                }
            }
            $this->info=$zym_6;
            $this->display();
        } else {
            $this->error('找不到指定的任务');
        }
    }
    public function powerAction()
    {
        if (IS_POST) {
            M('config')->where(array('key'=>'cron_power'))->edit(array('value'=>(1-C('cron_power'))));
            $this->success('操作成功');
        }
    }
}
